﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDeliverMajorProject.aspx.cs"
Inherits="ZX.WebApp.Crm.Deliver.AddDeliverMajorProject" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
<link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
<link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
<link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
<link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
<script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
<script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
<script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
<link href="../../Styles/default/calendar.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery.calendar.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
<script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
<script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
<script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
<script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
<script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
<link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
<link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    table, td
    {
        border: 0px solid #cccccc;
        border-collapse: collapse;
    }
    .tr1
    {
        border-bottom: 1px solid #cccccc;
    }
</style>
</head>
<body class="yui-skin-sam">
<form id="form1" runat="server">
<div>
    <div id="toolbar" style="margin-top: 12px; text-align: center;">
        <%if (Flag != "0" && strView == "")
            { %>
        <p id="returnBack" style="text-align: left">
            &nbsp; 退回原因：<span style="color: Red">*</span>&nbsp;
            <input type="text" id="backReason" title="不超过30个汉字" maxlength="30" style="width: 60%;" /><span
                class="span_font">保存则不需填写</span>
            <br />
        </p>
        <%} %>
        <button type="button" id="btnSave" name="btnSave">
            保存</button>
        <button type="button" id="btnPms" name="btnPms">
            保存</button>
        <button type="button" id="btnSsr" name="btnSsr">
            保存</button>
        <button type="button" id="btnScb" name="btnScb">
            保存</button>
        <button type="button" id="btnLate" name="btnLate">
            保存</button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" id="btnClose" name="btnClose">
            退回上一级</button>
    </div>
    <div class="fieldForm" id="fieldForm">
        <div id="content">
            <h3>
                基本信息</h3>
            <table class="table1">
                <tr>
                    <th>
                        <span>交付单号</span>
                    </th>
                    <td>
                        <asp:TextBox ID="Code" runat="server" Enabled="false" BackColor="#e7eaf4" CssClass="width60"></asp:TextBox>
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                    <th>
                        <span>申请日期</span>
                    </th>
                    <td>
                        <asp:TextBox ID="AddTime" runat="server" Enabled="false" BackColor="#e7eaf4" CssClass="width60"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <th width="10%">
                        <span style="color: Red">*</span><span>订单号</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="OrderProductID" name="OrderProductID" runat="server" />
                        <input type="text" id="txtOrderProductID" name="txtOrderProductID" disabled="disabled"
                            class="width60" runat="server" />
                        <button id="btnOrderProductID" name="2" type="button" onclick="change('1')" runat="server"
                            class="btnCheck">
                            选择</button>
                    </td>
                    <th width="10%">
                        <span>客户编码</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="CustomerCode" runat="server" disabled="disabled" class="width60" />
                    </td>
                    <th width="10%">
                        <span>客户名称</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="CustomerName" runat="server" disabled="disabled" title="<%=this.Value %>"
                            class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>应缴款</span>
                    </th>
                    <td>
                        <input type="text" id="Pay1" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>未缴款</span>
                    </th>
                    <td>
                        <input type="text" id="Pay2" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span style="color: Red">*</span> <span>负责交付人</span>
                    </th>
                    <td>
                        <input type="hidden" id="ClassFrontServer" />
                        <input type="text" id="txtClassFrontServer" runat="server" disabled="disabled" class="width60" />
                        <button id="btnClassFrontServer" name="Z" type="button" runat="server" onclick="change('0')"
                            class="btnCheck">
                            选择</button>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>客户经理</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerMgr" name="CustomerMgr" runat="server" />
                        <input type="text" runat="server" id="txtCustomerMgr" name="txtCustomerMgr" disabled="disabled"
                            class="width60" />
                        <button id="btnCustomerMgr" name="Z" type="button" runat="server" class="btnCheck"
                            style="height: 25px;">
                            选择</button>
                    </td>
                    <th>
                        <span>客户总监</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerDirector" runat="server" />
                        <input type="text" runat="server" id="txtCustomerDirector" disabled="disabled" class="width60" />
                        <button id="btnCustomerDirector" name="Z" type="button" runat="server" class="btnCheck" style="height: 25px;">
                            选择</button>
                    </td>
                    <th>
                        <span>分总</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerManager" runat="server" />
                        <input type="text" runat="server" id="txtCustomerManager" disabled="disabled" class="width60" />
                        <button id="btnCustomerManager" name="Z" type="button" runat="server" class="btnCheck" style="height: 25px;">
                            选择</button>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtXm" disabled="disabled" class="width60" />
                    </td>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                <tr style="display: none;">
                    <td id="tdState1" colspan="5" style="display: none;">
                        &nbsp;状态：
                    </td>
                    <td id="tdState2" style="display: none;">
                        <asp:DropDownList ID="DliverState" runat="server" CssClass="width65">
                        </asp:DropDownList>
                    </td>
                    <%--  <td>
                    &nbsp;填写时间：
                </td>
                <td colspan="3">
                    <input type="text" runat="server" id="txtXmTime" disabled="disabled" style="width: 150;
                        background: #e7eaf4;" />
                </td>--%>
                </tr>
            </table>
        </div>
        <div class="extendDiv">
            <button type="button" id="btnDelete1" name="btnDelete1">
                删除</button>
            <div id="con_two_1">
                <div id="con_1">
                </div>
            </div>
        </div>
        <div class="contentTable">
            <table id="pm" class="table1">
                <tr>
                    <th width="10%">
                        <span style="color: Red">*</span><span>项目经理</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="PM" runat="server" />
                        <input type="text" id="txtPM" runat="server" disabled="disabled" class="width60"
                            style="background: #e7eaf4;" />
                        <button id="btnPM" name="Z" runat="server" type="button" class="btnCheck">
                            选择</button>
                    </td>
                    <th width="10%">
                        <span style="color: Red">*</span><span>启动日期</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="txtStartDate" runat="server" class="width60" />
                    </td>
                    <th width="10%">
                        <span style="color: Red">*</span><span>项目成员</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="Memember" runat="server" />
                        <input type="text" id="txtMemember" runat="server" dtype="Z" disabled="disabled"
                            style="background: #e7eaf4;" class="width60" />
                        <button id="btnMemember" name="R" type="button" runat="server" class="btnCheck">
                            选择</button>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="AddUser" runat="server" />
                        <input type="text" runat="server" id="txtAddUser" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtAddTime" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>备注</span>
                    </th>
                    <td>
                        <input type="text" id="txtPmExplain" maxlength="30" title="不超过30个汉字" class="width60" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span> <span>实施天数</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtDay" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" class="width60" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>结项日期</span>
                    </th>
                    <td>
                        <input type="text" id="txtEndTime" runat="server" class="width60" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>离项日期</span>
                    </th>
                    <td>
                        <input type="text" id="txtLeaveDate" runat="server" class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>项目暂停时间</span>
                    </th>
                    <td>
                        <input type="hidden" id="Hidden2" runat="server" />
                        <input type="text" runat="server" id="txtPause" class="width60" />
                    </td>
                    <th>
                        <span>项目重启时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtReStart" class="width60" />
                    </td>
                    <td colspan="2">
                        <span class="span_font">(这一行根据需要填写)</span> &nbsp; &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="hdnEnd" runat="server" />
                        <input type="text" runat="server" id="txtEndUser" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtEndWriteTime" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>备注</span>
                    </th>
                    <td>
                        <input type="text" id="txtExplain" title="不超过30个汉字" maxlength="30" runat="server" class="width60" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span> <span>是否满意</span>
                    </th>
                    <td>
                        <asp:DropDownList ID="ddlSatisfy" runat="server" CssClass="width65">
                            <asp:ListItem Value="1">是</asp:ListItem>
                            <asp:ListItem Value="0">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td colspan="4">
                        &nbsp;<span id="backPay"><input id="chkDown" type="radio" name="a" value="0" />
                            退款20%以内
                            <input id="chkUp" type="radio" name="a" checked="checked" value="1" />退款20%以上
                        </span>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="hdnMyd" runat="server" />
                        <input type="text" runat="server" id="txtMydUser" disabled="disabled"  class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtMydTime" disabled="disabled"  class="width60" />
                    </td>
                    <th>
                        <span>备注</span>
                    </th>
                    <td>
                        <input type="text" id="txtMarketExplain" title="不超过30个汉字" maxlength="30" runat="server"  class="width60" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>服务人员</span>
                    </th>
                    <td>
                        <input type="hidden" id="hdnServiceName" />
                        <input type="text" id="txtServiceName" runat="server" disabled="disabled" style="background: #e7eaf4;"
                            class="width60" />
                        <button id="btnServiceName" name="R" type="button" runat="server" class="btnCheck">
                            选择</button>
                    </td>
                    <th>
                        <span>服务日期</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="ServiceDate"  class="width60" />
                    </td>
                    <th>
                        <span>顾问是否到场</span>
                    </th>
                    <td>
                        <asp:DropDownList ID="ddlAdvisor" runat="server" CssClass="width65">
                            <asp:ListItem Value="1">是</asp:ListItem>
                            <asp:ListItem Value="0">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>后续服务是否满意</span>
                    </th>
                    <td>
                        <asp:DropDownList ID="ddlService" runat="server" CssClass="width65">
                            <asp:ListItem Value="1">是</asp:ListItem>
                            <asp:ListItem Value="0">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <th>
                        <span><font style="color: Red">项目是否成功</font> </span>
                    </th>
                    <td>
                        <asp:DropDownList ID="ddlSuccess" runat="server" CssClass="width65">
                            <asp:ListItem Value="-1">--请选择--</asp:ListItem>
                            <asp:ListItem Value="1">是</asp:ListItem>
                            <asp:ListItem Value="0">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td colspan="2">&nbsp;</td>
                </tr>
            </table>
        </div>
    </div>
    <table id="tbReturn" class="tableContent" style="width: 100%" border="1">
        <tr>
            <td style="height: 16px; text-align: center" colspan="3">
                <asp:GridView ID="gvworkflowMessage" CssClass="GridViewStyle" runat="server" AutoGenerateColumns="False"
                    Width="100%">
                    <Columns>
                        <asp:BoundField DataField="WorkFlowNo" HeaderText="流程编号">
                            <ItemStyle Width="8%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="TaskInstanceCaption" HeaderText="任务名称">
                            <ItemStyle Width="10%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="FlowCaption" HeaderText="流程名称">
                            <ItemStyle Width="10%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="OperatedDes" HeaderText="处理者">
                            <ItemStyle Width="10%" />
                        </asp:BoundField>
                        <asp:BoundField DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False" DataField="taskEndTime"
                            HeaderText="任务结束时间">
                            <ItemStyle Width="10%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Message" HeaderText="审批意见">
                            <ItemStyle Width="15%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SuccessMsg" HeaderText="状态">
                            <ItemStyle Width="10%" />
                        </asp:BoundField>
                    </Columns>
                    <FooterStyle CssClass="FooterStyle" />
                    <RowStyle CssClass="RowStyle" />
                    <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                    <PagerStyle CssClass="PagerStyle" />
                    <SelectedRowStyle CssClass="SelectedRowStyle" />
                    <HeaderStyle CssClass="HeaderStyle" />
                    <EditRowStyle CssClass="EditRowStyle" />
                    <AlternatingRowStyle CssClass="AltRowStyle" />
                </asp:GridView>
            </td>
        </tr>
    </table>
</div>
<div id="dialog1" class="yui-pe-content">
    <div class="hd">
        信息选择</div>
    <div class="bd">
        <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
            margin: 0px; padding: 0px;"></iframe>
    </div>
</div>
<input type="hidden" id="ID" runat="server" />
<input type="hidden" id="WorkFlowInsId" runat="server" />
<input type="hidden" id="WorkTaskInsId" runat="server" />
</div>
</form>
<form id="form2" style="display: none" action="">
<textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
</form>
</body>
<script type="text/javascript">
var entity = "<% =EntityName %>", addUser="<%=addUser %>",
    action = "<% =DataAction %>",
    flag = "<%=Flag %>",strView="<%=strView %>",
    WorkFlowId="<%=strWorkFlowId %>",WorkTaskId="<%=strWorkTaskId %>",strOperStatus="<%=strOperStatus %>", strDescript="<%=strDescript %>",
    OperatorInstanceId="<%=strOperatorInstanceId %>",WorkflowInsId="<%=strWorkflowInsId %>",
    WorkTaskInsId=$("#WorkTaskInsId").val(),strBackPay="<%=strBackPay %>",
    ListRecord=[<%=ListRecord %>];
        
var  DeliverMajorInfo = [<%=ListDeliverMajorInfo %>];        
var myDataSource1, mDataTable1;
var getTsid=$("#WorkTaskInsId").val();
var vid = $("#ID").val();
var btnSave = "",btnPms="",btnSsr="",btnScb="",btnLate="", btnClose = "", condition = "";
<asp:Literal ID="EditTemplate" runat="server"></asp:Literal>
(function () {  
    var trs = $("#pm tr"); 
//        if(flag=="0"){ //新增
//            $('#DliverState').attr("disabled","true");
//            $("#DliverState").get(0).selectedIndex = 2;
//            $("#tdState1").css("display","none");
//            $("#tdState2").css("display","none");
//        }

    if (strView!="check") {
    

    if(strDescript=="xmqd"){
        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=2){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else if(strDescript=="jajd"){
        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=6){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else if(strDescript=="jgdc"){
        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=9){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else if(strDescript=="hxfw"){
        $("#chkDown").attr("disabled",true);
        $("#chkUp").attr("disabled",true);
        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=12){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else{    
        for (var i = 0; i < trs.length; i++) {
            trs[i].style.display = "none"; 
        }
    }  }
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
    Event.onDOMReady(function () {
        var layout = new YAHOO.widget.Layout({
            units: [
            { position: 'bottom', height: 90, body: 'toolbar',resize: true, gutter: '1 1 1 1', scroll: true, zIndex: 2 },
            { position: 'center', body: 'fieldForm', gutter: '0 1 1 1', scroll: true }
            ]
        });
        layout.render();
    });
})();

//退回上一节点
var Close = function () {
    if($("#backReason").val()==""){
        alert("请填写退回原因");
        $("#backReason").focus();
        return;
    }
    var vMessage = $("#backReason").val();
    if (confirm("您确定退回?")) {
    setTimeout(function () {
                var btn = document.getElementById("btnClose");
                btn.disabled = true;
                var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=CrmDeliverProjectUnAgree&msg=" + encodeURI(vMessage) + "" +
            "&OperatorInstanceId=" + OperatorInstanceId + "&WorkflowId=" + WorkFlowId + "&WorktaskId=" + WorkTaskId + "&WorkflowInsId=" + WorkflowInsId + "&WorktaskInsId=" + WorkTaskInsId + "";
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
                    } else {
                        alert("数据保存失败!");
                        return;
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
                setTimeout(function () { btn.disabled = false }, 10000);
            }, 10);
            
    }
}
var csNum;
var change=function(obj){
    csNum=obj
}

YAHOO.example.init = function () {
    function onButtonClick(p_oEvent) {
        switch (this.get("id")) {    
            case "btnSave":
                Save(0);
                break;
            case "btnClose":
                Close();
                break;
            case "btnPms":
                SavePms();
                break;
                case "btnSsr":
                SaveSsr();
                break;
                case "btnScb":
                SaveScb();
                break;
                case "btnLate":
                SaveLate();
                break;
                case "btnDelete1":
            handleDelete();
            break;
            default:
                break;
        }
    }
    YAHOO.util.Event.onContentReady("toolbar", function () {  
        btnSave = new YAHOO.widget.Button("btnSave");
        btnSave.on("click", onButtonClick);
        btnPms = new YAHOO.widget.Button("btnPms");
        btnPms.on("click", onButtonClick);
        btnSsr = new YAHOO.widget.Button("btnSsr");
        btnSsr.on("click", onButtonClick);
        btnScb = new YAHOO.widget.Button("btnScb");
        btnScb.on("click", onButtonClick);
        btnLate = new YAHOO.widget.Button("btnLate");
        btnLate.on("click", onButtonClick);
        btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick); 
        if(strView=="check"){btnPms._button.style.display = "none";
            $("#btnPms").attr('disabled', "true");
            btnSsr._button.style.display = "none";
            $("#btnSsr").attr('disabled', "true");
            btnScb._button.style.display = "none";
            $("#btnScb").attr('disabled', "true");
            btnLate._button.style.display = "none";
            $("#btnLate").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            }else{
        if(strDescript=="xmqd"){    
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnSsr._button.style.display = "none";
            $("#btnSsr").attr('disabled', "true");
            btnScb._button.style.display = "none";
            $("#btnScb").attr('disabled', "true");
            btnLate._button.style.display = "none";
            $("#btnLate").attr('disabled', "true");
        }
        else if(strDescript=="jajd"){
            btnPms._button.style.display = "none";
            $("#btnPms").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnScb._button.style.display = "none";
            $("#btnScb").attr('disabled', "true");
            btnLate._button.style.display = "none";
            $("#btnLate").attr('disabled', "true");
        }
        else if(strDescript=="jgdc"){
            btnPms._button.style.display = "none";
            $("#btnPms").attr('disabled', "true");
            btnSsr._button.style.display = "none";
            $("#btnSsr").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnLate._button.style.display = "none";
            $("#btnLate").attr('disabled', "true");
        }
        else if(strDescript=="hxfw"){
            btnPms._button.style.display = "none";
            $("#btnPms").attr('disabled', "true");
            btnSsr._button.style.display = "none";
            $("#btnSsr").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnScb._button.style.display = "none";
            $("#btnScb").attr('disabled', "true");
        }
        else{ //新增时设置按钮隐藏
            btnPms._button.style.display = "none";
            $("#btnPms").attr('disabled', "true");
            btnSsr._button.style.display = "none";
            $("#btnSsr").attr('disabled', "true");
            btnScb._button.style.display = "none";
            $("#btnScb").attr('disabled', "true");
            btnLate._button.style.display = "none";
            $("#btnLate").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true");
        }    }
    });
        
    btnDeletes1 = new YAHOO.widget.Button("btnDelete1");
    btnDeletes1.on("click", onButtonClick);
    if (flag == 1 && strView!="unDone") {
        btnDeletes1._button.style.display = "none";
    } else {
        btnDeletes1._button.style.display = "";
    }

} ();
//选择对应的方法和ID
var _fn, _id;
function ShowDialog(fn, id,src) {
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}
/* 对应的方法和ID*/
var _fn, _id;
function ShowDialog1(fn, id,src) {
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}
YAHOO.namespace("example.container");
YAHOO.util.Event.onDOMReady(function () {
    var handleSubmit = function () {
        var editwindow = document.getElementById("EditUIWindow1");
        if (editwindow) {
            editwindow.contentWindow.ChooseInfo();    
            if(csNum=="1"){ LoadOrderProductInfo();
            loadPay();
            }
        }
        YAHOO.example.container.dialog1.hide();
    };
    var handleCancel = function () {
        this.cancel();
    };
    var handleSuccess = function (o) {
        var response = o.responseText;
        response = response.split("<!")[0];
        document.getElementById("resp").innerHTML = response;
    };
    var handleFailure = function (o) {
        alert("Submission failed: " + o.status);
    };
    YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					        { width: "580px",
					            height: "450px",
					            fixedcenter: true,
					            visible: false,
					            draggable: true,
					            close: true,
					            autofillheight: "body",
					            constraintoviewport: true,
					            buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								        { text: "取消", handler: handleCancel}]
					        });
    YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
    YAHOO.example.container.dialog1.render();
});
//根据订单产品ID获取订单信息
var LoadOrderProductInfo = function () {           
    var vCId = "OrderCode='" + $("#txtOrderProductID").val() + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_DeliverOrderProduct&customCondition=" + vCId + "", //条件 
    {success: function (res) {
        try {                     
            var str = res.responseText;
            var arr = [];
            var obj = eval(str); 
            $('#CustomerCode').val(obj[0].CustomerCode);
            $('#CustomerName').val(obj[0].CustomerName);
            //$('#Account').val(obj[0].Amount);
            $('#Pay1').val(obj[0].AccountReceivable);
            $('#Pay2').val(obj[0].AccountReceivable - obj[0].ResignMoney);
            $('#CustomerSource').val(obj[0].CustomerOrigin);    
            $('#CustomerMgr').val(obj[0].CustomeerMgr);
            $('#txtCustomerMgr').val(obj[0].CManager);

            LoadCustomerDirector(obj[0].OrderID);    
            LoadData1();
        }
        catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
var loadPay = function () {
var vid = $("#OrderProductID").val();
YAHOO.util.Connect.asyncRequest('POST', "../../Extend/AjaxData/CustomOperating.aspx?entity=CrmDeliverMajorP_Order&action=insert&cid=" + vid, //条件 
        {success: function (res) {
            try {
                var str = res.responseText;
                if (str == "1") {
                    alert("您选择的订单的项目交付单不属于待交付状态");
                    location.reload(false);
                }
            }
            catch (e) {
            }
            finally {
            }
        }, failure: function () { }
    });
}
//加载显示客户总监和分总
var LoadCustomerDirector = function (OrderId) {
    var vCId = "OrderId='" + OrderId + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_CrmOrderPerson&customCondition=" + vCId + "",
    { success: function (res) {
        try {
            var str = res.responseText;
            var arr = [];
            var obj = eval(str);
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].ClassValue == "CustomerZJ") {
                    $("#CustomerDirector").val(obj[i].UserId);
                    $("#txtCustomerDirector").val(obj[i].UserName);
                }
                if (obj[i].ClassValue == "CustomerFZ") {
                    $("#CustomerManager").val(obj[i].UserId);
                    $("#txtCustomerManager").val(obj[i].UserName);
                }
            }
        }
        catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
//加载数据
var LoadData1 = function () {
    var vCId = "OrderCode='" + $("#txtOrderProductID").val() + "'";
        YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_DeliverOrderProduct&customCondition=" + vCId + "", //条件 
            {success: function (res) {
            try {
                var str = res.responseText;
                var arr = [];          
                var obj = eval(str);
                                   
                for (var i = 0; i < obj.length; i++) {
                if(obj[i].TypeName=="项目类"){
                    var entity = {};
                    entity.ProductName = obj[i].ProductName;
                    entity.ID = obj[i].ProductId;
                    entity.AccountReceivable = obj[i].AccountReceivable;
                    entity.ResignMoney = obj[i].ResignMoney;
                    entity.Amount=obj[i].Amount;
                    entity.TypeName=obj[i].TypeName;
                    entity.ProductCode = obj[i].ProductCode;
                    arr.push(entity);  
                    if(i>0){
                        handleAdd(arr.length);
                    }
                    }
                }
                    
                ListRecord = arr;
                hideCol();
            }
            catch (e) {
            }
            finally {
            }
        }, failure: function () { }
    });
} 
//新增行
var handleAdd = function (objNum) {
mDataTable1.set("sortedBy", null);
index = mDataTable1.getRecordSet()._records.length;
    
var entity = [{ ID: "", ProductCode: "", TypeName: "", ProductName: "", Amount: "", AccountReceivable: "",
            ResignMoney: ""
}];
if(index<objNum){
    mDataTable1.addRows(entity, index);
}
}
//删除行
var handleDelete = function () {
var recordID = mDataTable1.getSelectedRows()[0];
index = mDataTable1.getRecordSet()._records.length;
if (recordID != null && recordID.length != 1) {
    if (mDataTable1.getRecordSet()._records.length == 1) {
        alert("最后一行不能删除");
        return;
    };
    mDataTable1.deleteRow(recordID);
} else {
    alert("请选中一行后删除！");
}
}
var format1 = function (elCell, oRecord, oColumn, sData) {  
    var str1 = [], tempData = "", strTemp = [], y = 0;
    var id = "id" + Math.random(); 
    if (flag == 1) {
        str1.push("<select id='" + id + "' onchange='ChangeEvent2(this);' disabled='disabled' name='ProductName' style='width:100%;'>");
    } else {
        str1.push("<select id='" + id + "' onchange='ChangeEvent2(this);' name='ProductName' style='width:100%;'>");
    } 
    str1.push("<option value='00000000-0000-0000-0000-000000000000'> </option>");
    if(flag=="1"){
        str1.push("<option value='' selected> "+sData+"</option>");
    }else{
        for (var i = 0; i < ListRecord.length; i++) {      
            if(ListRecord[i].Caption==""){
                str1.push("<option value='"+ListRecord[i].ID+"'>场次费</option>");
            }else{
                str1.push("<option value='"+ListRecord[i].ID+"'> "+ListRecord[i].ProductName+"</option>");
            }
        }
    }
    str1.push("</select>");
    elCell.innerHTML = str1.join("");
}
var format2 = function (elCell, oRecord, oColumn, sData) {
    if(sData==null||sData=="")  {  
        elCell.innerHTML = "<input type=\"text\" value=\"\" onchange='ChangeEvent1(this);' disabled='disabled' size='18' maxlength='18' name='TypeName' style='width:95%;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" onchange='ChangeEvent1(this);' disabled='disabled' size='18' maxlength='18' name='TypeName' style='width:95%;'>";
    } 
}
var format3 = function (elCell, oRecord, oColumn, sData) {
    if(sData==null||sData=="")  { 
        elCell.innerHTML = "<input type=\"text\" value=\"\" onchange='ChangeEvent1(this);' disabled='disabled' size='30' maxlength='30' name='ProductCode' style='width:95%;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" onchange='ChangeEvent1(this);' disabled='disabled' size='30' maxlength='30' name='ProductCode' style='width:95%;'>";
    } 
}
var format4 = function (elCell, oRecord, oColumn, sData) {
    if(sData==null||sData==""){
        elCell.innerHTML = "<input type=\"text\" value=\"\" onchange='ChangeEvent1(this);' disabled='disabled' name='Amount' style='width:95%;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" onchange='ChangeEvent1(this);' disabled='disabled' name='Amount' style='width:95%;'>";
    } 
}
var format5 = function (elCell, oRecord, oColumn, sData) {
    if(sData==null||sData=="")  {elCell.innerHTML = "<input type=\"text\" value=\"\" onchange='ChangeEvent1(this);'  disabled='disabled' size='10' maxlength='10' name='AccountReceivable' style='width:95%;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" onchange='ChangeEvent1(this);'  disabled='disabled' size='10' maxlength='10' name='AccountReceivable' style='width:95%;'>";
    }    
}
var format6 = function (elCell, oRecord, oColumn, sData) {
    if(sData==null||sData==""){ 
        elCell.innerHTML = "<input type=\"text\" value=\"\" onchange='ChangeEvent1(this);' size='10' disabled='disabled' maxlength='10' name='ResignMoney' style='width:95%;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" onchange='ChangeEvent1(this);' size='10' disabled='disabled' maxlength='10' name='ResignMoney' style='width:95%;'>";
    }
}
YAHOO.util.Event.addListener(window, "load", function () {
    BindData();
    hideCol();
});
var BindData = function () {
    YAHOO.example.RowDataMod = function () {
        var myColumnDefs1 = [     
        { key: "ID", label: "ID", resizeable: true },
        { key: "ProductName", label: "产品名称", resizeable: true, formatter: format1,width:200 },
        { key: "TypeName", label: "产品类型", resizeable: true, formatter: format2 },
        { key: "ProductCode", label: "产品编码", resizeable: true, formatter: format3 },
        { key: "Amount", label: "数量", resizeable: true, formatter: format4 },
        { key: "AccountReceivable", label: "应收金额", resizeable: true, formatter: format5 },
        { key: "ResignMoney", label: "已收金额", resizeable: true, formatter: format6 }
   
        ];
        myDataSource1 = new YAHOO.util.DataSource([{ ID: "", ProductCode: "", TypeName: "", ProductName: "", Amount: "", AccountReceivable: "",
            ResignMoney: ""
        }]);
        myDataSource1.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        myDataSource1.responseSchema = {
            fields: ["ID", "ProductName", "TypeName", "ProductCode", "Amount", "AccountReceivable", "ResignMoney"]
        };
        var myDataTable1 = new YAHOO.widget.DataTable("con_1",
        myColumnDefs1, myDataSource1, { selectionMode: "single" });
        mDataTable1 = myDataTable1;
        var i1 = 1,
        bReverseSorted1 = false;
        var trackReverseSorts1 = function (oArg) {
            bReverseSorted1 = (oArg.dir === YAHOO.widget.DataTable.CLASS_DESC);
        };
        myDataTable1.subscribe("rowMouseoverEvent", myDataTable1.onEventHighlightRow);
        myDataTable1.subscribe("rowMouseoutEvent", myDataTable1.onEventUnhighlightRow);
        myDataTable1.subscribe("rowClickEvent", myDataTable1.onEventSelectRow);
        myDataTable1.subscribe("checkboxClickEvent", function (oArgs) {
            var elCheckbox = oArgs.target;   
            var oRecord = this.getRecord(elCheckbox);
            oRecord.setData("iSun_Selected", elCheckbox.checked);
        });
        GetFormValue1();
        return {
            ds: myDataSource1,
            dt: myDataTable1
        };
    } ();
}
//隐藏/栏位
function hideCol() {
    mDataTable1.hideColumn(parseInt(0)); mDataTable1.refreshView();
}
//值改变事件
var ChangeEvent1 = function (oArgs) {
    var f = oArgs.name;
    var v = oArgs.value;
    setValue1(f, v);
}
var ChangeEvent2 = function (oArgs) {
    var f = oArgs.name;
    var v = oArgs.value;
    setValue2(f, v);
}
var setValue2 = function (f, v) {
    var recordID = mDataTable1.getSelectedRows()[0];
    var record = mDataTable1.getRecord(recordID);
    record._oData[f] = v;  
    for (var i = 0; i < ListRecord.length; i++) {  
        if (ListRecord[i].ID == v) {
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=TypeName]")[0]).val(ListRecord[i].TypeName);
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ProductCode]")[0]).val(ListRecord[i].ProductCode);
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=Amount]")[0]).val(ListRecord[i].Amount);
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ResignMoney]")[0]).val(ListRecord[i].ResignMoney);
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=AccountReceivable]")[0]).val(ListRecord[i].AccountReceivable);
        }
    }
}
var GetFormValue1 = function () {               
    for (var i = 0; i < DeliverMajorInfo.length; i++) {  
        SetFormValue1(DeliverMajorInfo);
    }
}
var SetFormValue1 = function (obj) {    
    var arr = eval(obj);
    myDataSource1.liveData = arr;
    mDataTable1.getDataSource().sendRequest(null, { success: mDataTable1.onDataReturnInitializeTable }, mDataTable1);
}
//f=字段名 v=值
var setValue1 = function (f, v) {
    var recordID = mDataTable1.getSelectedRows()[0];
    var record = mDataTable1.getRecord(recordID);
    record._oData[f] = v;
}
 
//刷新父窗体数据
function RefreshDataParent() {
    if (parent.NeedRefreshPage != null) {
        if (typeof (parent.NeedRefreshPage.LoadData) == "function") {
            parent.NeedRefreshPage.RefreshData();
        }
    }
}
//是否满意值改变事件
$('#ddlSatisfy').change(function () {         
var OptionValue = $(this).children('option:selected').val();
    if(OptionValue=="0")
    {
        document.getElementById("backPay").style.display="";                                    
    } else{
        document.getElementById("backPay").style.display="none";
    }
});
  
//保存
var Save = function (obj) {   
    $("#DliverState").get(0).selectedIndex = 2;
    setValue();
    if(strView!="unDone"){
        if(instance[0].ClassFrontServer == null || instance[0].ClassFrontServer ==  ""){
            alert("负责交付人不能为空!");
            return;
        }
        var list = mDataTable1.getRecordSet()._records;
        var elist = [];
        instance[0].ProduectList = "";
        for (var i = 0; i < list.length; i++) {
            if (list[i]._oData.ProductName ==null || list[i]._oData.ProductName ==  "") {
                alert("产品名称不能为空!");
                return;
            }
            elist.push(list[i]._oData);
        }
        for (var j = 0; j < elist.length; j++) {
            instance[0].ProduectList += "@" + elist[j].ProductName + "︾" + $("#OrderProductID").val()+ "︾";
        }
   }else{
        if(instance[0].ClassFrontServer == null || instance[0].ClassFrontServer ==  ""){
            alert("请修改负责交付人!");
            return;
        }  
    }
    var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
    $("#jsonDataContent").val(json);
    setTimeout(function () {
        var btn = document.getElementById("btnSave");
        btn.disabled = true;
        trySave();
        setTimeout(function () { btn.disabled = false }, 10000);
    }, 10);   
}
//保存项目人员
var SavePms=function(){
$("#DliverState").get(0).selectedIndex =1;
    setPmsValue();
    var orderid="<%=strOrderId %>",productid="<%=strProductId %>";
    if(strOperStatus!="1"){
        if(instance[0].PM==null||instance[0].PM=="") {
            alert("项目经理不能为空!");
            return;
        }
        if(instance[0].BeginDate==null||instance[0].BeginDate=="") {
            alert("启动日期不能为空!");
            return;
        }
        if(instance[0].PMemember==null||instance[0].PMemember=="") {
            alert("项目成员不能为空!");
            return;
        }  
    }else{ 
    var tempPm="<%=strPM %>",tempBd="<%=strStartDate %>",tempPmb="<%=strMemember %>",tempEpx="<%=strExplain %>" ;              
        /*instance[0].PM=tempPm;  
        instance[0].BeginDate=tempBd; 
        instance[0].PMemember=tempPmb; 
        instance[0].PExplain=tempEpx;*/ 
    } 
                                  
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&stateId="+$("#DliverState").val()+"&view="+strOperStatus+"&orderid="+orderid+"&productid="+productid+"&PM="+instance[0].PM+"&BeginDate="+instance[0].BeginDate+"&PMemember="+instance[0].PMemember+"&PExplain="+encodeURI(instance[0].PExplain)+"&ProjectUser="+instance[0].ProjectUser+"&ProjectDate="+instance[0].ProjectDate+"&flag=1&entity="+entity+"&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    setTimeout(function () {
                var btn = document.getElementById("btnPms");
                btn.disabled = true;
                var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                setTimeout(function () { btn.disabled = false }, 10000);
            }, 10);
       
}
//实施资料
var SaveSsr=function(){ 
      
    setSsrValue();
    if(instance[0].DateSum==null||instance[0].DateSum=="") {
        alert("实施天数不能为空!");
        return;
    }
    if(instance[0].EndDate==null||instance[0].EndDate=="") {
        alert("结案日期不能为空!");
        return;
    } 
    var endDate = "<%=strEndDate %>";
//        if (instance[0].EndDate > endDate) {
//            alert("结案日期不能大于当前日期!");
//            $('#txtEndTime').focus();
//            return ;
//        }    
    if (instance[0].EndDate < $("#txtStartDate").val()) {
        alert("结案日期不能早于启动日期!");
        $('#txtEndTime').focus();
        return ;
    }
    if (instance[0].LeaveDate==null||instance[0].LeaveDate=="") {
        alert("离项日期不能为空!");
        $('#txtLeaveDate').focus();
        return ;
    }                   
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&view="+strView+"&DateSum="+instance[0].DateSum+"&ProejectPauseDate="+instance[0].ProejectPauseDate+"&ProjectRestartDate="+instance[0].ProjectRestartDate+"&EndDate="+instance[0].EndDate+"&SsExplain="+encodeURI(instance[0].SsExplain)+"&leaveDate="+instance[0].LeaveDate+"&SsUser="+instance[0].SsUser+"&SsDate="+instance[0].SsDate+"&flag=1&entity=CrmDeliverSsr&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    setTimeout(function () {
                var btn = document.getElementById("btnSsr");
                btn.disabled = true;
                var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                setTimeout(function () { btn.disabled = false }, 10000);
            }, 10);
      
}
//实施资料赋值
var setSsrValue=function(){
    instance[0].DateSum=$("#txtDay").val();
    instance[0].LeaveDate=$("#txtLeaveDate").val();
    instance[0].EndDate=$("#txtEndTime").val();
    instance[0].ProejectPauseDate=$("#txtPause").val();
    instance[0].ProjectRestartDate=$("#txtReStart").val();
    instance[0].SsExplain=$("#txtExplain").val();
    instance[0].SsUser=$("#hdnEnd").val();
    instance[0].SsDate=$("#txtEndWriteTime").val(); 
}
//后续服务
var SaveLate = function(){
    setLateValue();
    var strOrderProduct="<%=strOrderProduct %>"; 
    $("#DliverState").get(0).selectedIndex = 4;  
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&orderid="+$("#txtOrderProductID").val()+"&DliverState="+$("#DliverState").val()+"&strOrderProduct="+strOrderProduct+"&Success="+instance[0].Success+"&ServiceName="+encodeURI(instance[0].ServiceName)+"&ServiceDate="+encodeURI(instance[0].ServiceDate)+"&ServiceSatisfy="+instance[0].ServiceSatisfy+"&AdvisorIsAt="+instance[0].AdvisorIsAt+"&flag=1&entity=CrmDeliverHxfw&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        setTimeout(function () {
                var btn = document.getElementById("btnLate");
                btn.disabled = true;
                var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                setTimeout(function () { btn.disabled = false }, 10000);
            }, 10);
            
}
//后续服务赋值
var setLateValue=function(){
    instance[0].Success=$("#ddlSuccess").val();
    instance[0].ServiceName=$("#txtServiceName").val();
    instance[0].ServiceDate=$("#ServiceDate").val();
    instance[0].AdvisorIsAt=$("#ddlAdvisor").val();
    instance[0].ServiceSatisfy=$("#ddlService").val();
}
//市场部
var SaveScb=function(){  
    setScbValue();
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&WellDegree="+instance[0].WellDegree+"&UnSatisfy="+instance[0].UnSatisfy+"&Explain="+encodeURI(instance[0].Explain)+"&DegreeUser="+instance[0].DegreeUser+"&DegreeDate="+instance[0].DegreeDate+"&flag=1&entity=CrmDeliverScb&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    setTimeout(function () {
        var btn = document.getElementById("btnScb");
        btn.disabled = true;
        var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
        setTimeout(function () { btn.disabled = false }, 10000);
    }, 10);    
}
//市场部赋值
var setScbValue=function(){
    instance[0].WellDegree=$("#ddlSatisfy").val();
    if($("#ddlSatisfy").val()=="1"){
        instance[0].UnSatisfy=-1;       
    }else{
        var chkTemp=document.getElementsByName("a");
        if(chkTemp[1].checked==true){
            instance[0].UnSatisfy=1;
        }else{
            instance[0].UnSatisfy=0;
        }
    }
    instance[0].DegreeUser=$("#hdnMyd").val();
    instance[0].DegreeDate=$("#txtMydTime").val();
    instance[0].Explain=$("#txtMarketExplain").val();
}
var setPmsValue=function(){      
    instance[0].PM=$("#PM").val(); 
    instance[0].BeginDate=$("#txtStartDate").val();
    instance[0].PMemember=$("#Memember").val();
    instance[0].PExplain=$("#txtPmExplain").val();
    instance[0].ProjectUser=$("#AddUser").val();
    instance[0].ProjectDate=$("#txtAddTime").val();
    instance[0].WorkFlowId = WorkFlowId;
    instance[0].WorkTaskId = WorkTaskId;
    instance[0].WorkFlowInsId = $("#WorkFlowInsId").val();
    instance[0].WorkTaskInsId = $("#WorkTaskInsId").val();
}
var setValue = function(){
    instance[0].Code = $("#Code").val();
    instance[0].exp2 = $("#OrderProductID").val();
    instance[0].DliverState=$("#DliverState").val();
    instance[0].ClassFrontServer = $("#ClassFrontServer").val();
    instance[0].WorkFlowId = WorkFlowId;
    instance[0].WorkTaskId = WorkTaskId;
    instance[0].WorkFlowInsId = $("#WorkFlowInsId").val();
    instance[0].WorkTaskInsId = $("#WorkTaskInsId").val();
    instance[0].CustomerMgr = $("#CustomerMgr").val();
    instance[0].CustomerDirector = $("#CustomerDirector").val();
    instance[0].CustomerManager = $("#CustomerManager").val();
}

function trySave(){   
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action="+action+"&cName="+encodeURI($("#CustomerName").val())+"&view="+strView+"&flag=1&entity="+entity+"";
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
}

var responseSuccess = function (res) {
    try {                    
        var str = res.responseText;
        if (str == "1") { 
            RefreshDataParent();
            window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
        }
        else {
            alert(str);
        }
    } catch (e) {
    }
    finally {
    }
}

var responseFailure = function (error) {
    alert("数据错误：" + error.statusText);
}

var callback = {
    success: responseSuccess,
    failure: responseFailure
};

$(document).ready(function () {   
    $('#txtStartDate').cld();
    $('#txtEndTime').cld();
    $('#txtPause').cld();
    $('#txtReStart').cld();
    $('#txtLeaveDate').cld();
    $('#ServiceDate').cld();
    if($("#txtAddTime").val()==""&&strView!="check"){
        myDate = new Date();      
        $("#txtAddTime").val(myDate.getYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate());
    }
    var chkTemp=document.getElementsByName("a");
    if($("#ddlSatisfy").val()=="0"){    
        var chkTemp=document.getElementsByName("a");
        if(strBackPay=="1"){
            chkTemp[1].checked=true;
        }else{
            chkTemp[0].checked=true;
        } 
    }else{
        document.getElementById("backPay").style.display="none";  
    }
});
</script>
</html>
